package org.chimi.rr4s.domain;

import java.util.List;

import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.RelationshipOperationsRepository;

public interface UserRepository extends GraphRepository<User>,
		RelationshipOperationsRepository<User> {

	@Query("start u=node:USER(id={0}) "
			+ "match u-[:VIEWED]->i<-[:VIEWED]-user "
			+ "return user, count(*) as count order by count desc")
	public List<UserResult> findSimiliarUsersByViewed(String userId);

	@Query("start u=node:USER(id={0}) " + "match u-[:LIKED]->i<-[:LIKED]-user "
			+ "return user, count(*) as count order by count desc")
	public List<UserResult> findSimiliarUsersByLiked(String userId);

	@Query("start u=node:USER(id={0}) "
			+ "match u-[:BOUGHT]->i<-[:BOUGHT]-user "
			+ "return user, count(*) as count order by count desc")
	public List<UserResult> findSimiliarUsersByBought(String userId);
}
